package com.neuedu.service.Imp;

import com.neuedu.dao.Imp.ShopDaoImp;
import com.neuedu.dao.ShopDao;
import com.neuedu.pojo.PageResult;
import com.neuedu.pojo.Shop;
import com.neuedu.service.ShopService;

import java.util.List;

public class ShopServiceImp implements ShopService {
    private ShopDao shopDao = new ShopDaoImp();
    @Override
    public Integer addShop(String shopName, String shopAddress, String shopExplain, String shopImg, String shopCategoryId, String startPrice, String deliveryPrice, String remarks,String status, String startTime, String endTime, String recommend, String businessId) {
        try{
            return shopDao.addShop(shopName,shopAddress,shopExplain,shopImg,shopCategoryId,startPrice,deliveryPrice,remarks,status,startTime,endTime,recommend,businessId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    // 分页查询信息


    @Override
    public PageResult<List<Shop>> getShop(String currentPage, String pageSize, String businessId) {
        try{
            List<Shop> shops = shopDao.getShop(currentPage,pageSize,businessId);

            Long l = shopDao.shopLong(businessId);

            PageResult<List<Shop>> pageResult = new PageResult<>();
            // 手动添加数据
            pageResult.setTotal(l);
            pageResult.setDatas(shops);

            return pageResult;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    // 条件查询


    @Override
    public PageResult<List<Shop>> getsShop(String currentPage, String pageSize, String shopName, String status) {
        try{
            List<Shop> shops = shopDao.getsShop(currentPage,pageSize,shopName,status);

            Long l = shopDao.shopLongs();

            PageResult<List<Shop>> pageResult = new PageResult<>();
            // 手动添加数据
            pageResult.setTotal(l);
            pageResult.setDatas(shops);

            return pageResult;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Integer updateShop(String shopName, String shopAddress, String shopExplain, String shopImg, String shopCategoryId, String startPrice, String deliveryPrice, String remarks, String startTime, String endTime,String status, String shopId) {
        try{
            return shopDao.updateShop(shopName,shopAddress,shopExplain,shopImg,shopCategoryId,startPrice,deliveryPrice,remarks,startTime,endTime,status,shopId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Integer updateStatus(String status,String shopName) {
        try{
            return shopDao.updateStatus(status,shopName);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Integer delShop(String shopId) {
        try{
            return shopDao.delShop(shopId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
